package com.wedimob.slideshare.task;

import java.net.URL;
import java.text.DecimalFormat;

public abstract class Task<I, O> implements Runnable {
	private final TaskType type;
	protected O output;
	protected I input;
	protected Exception e;
	protected PoolExecutor pool;
	protected int timeout;
	protected int limit;

	public Task(TaskType type, PoolExecutor pool, I input, int limit,
			int timeout) {
		this.pool = pool;
		this.input = input;
		this.limit = limit;
		this.timeout = timeout;
		this.type = type;
	}

	public O getOutput() {
		return output;
	}

	public I getInput() {
		return input;
	}

	public Exception getError() {
		return e;
	}

	public TaskType getType() {
		return type;
	}

	static public DecimalFormat decFormat = new DecimalFormat("0000");
	
	static public boolean accept(URL url, String urlbase) {
	    if (url == null || urlbase == null)
	        return false;
	    
	    return url.toString().contains(urlbase);
	}
}
